{extend name="common:base" /}
{block name="content"}
<form class="form-horizontal" role="form" action="{:url('save',['id'=>$category.id])}" method="post">
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="type"> 类型</label>
    <div class="col-sm-9">
    <select id="type" name="type" class="col-xs-10 col-sm-5">
        <option value="0"{eq name="category.type" value="0"} selected="selected"{/eq}>普通栏目</option>
        <option value="1"{eq name="category.type" value="1"} selected="selected"{/eq}>单页栏目</option>
        <option value="2"{eq name="category.type" value="2"} selected="selected"{/eq}>外部链接</option>
    </select>
    <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">分类类型。</span>
        </span>
    </div>
</div>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="form-field-0"> 父类</label>
    <div class="col-sm-9">
    <select id="pid" name="pid" class="col-xs-10 col-sm-5">
        <option value="0"{eq name="category.pid" value="0"} selected="selected"{/eq}>顶级分类</option>
        {volist name="categories" id="v"}
        <option value="{$v.id}"{eq name="category.pid" value="$v.id"} selected="selected"{/eq}>{$v.name}</option>
        {notempty name="v.children"}
        {volist name="v.children" id="vv"}
        <option value="{$vv.id}"{eq name="category.pid" value="$vv.id"} selected="selected"{/eq}>┣━{$vv.name}</option>
        {notempty name="vv.children"}
        {volist name="vv.children" id="vvv"}
        <option value="{$vvv.id}"{eq name="category.pid" value="$vvv.id"} selected="selected"{/eq}>┣━━{$vvv.name}</option>
        {/volist}
        {/notempty}
        {/volist}
        {/notempty}
        {/volist}
    </select>
    <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">选择所属分类。</span>
        </span>
    </div>
</div>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="name"> 分类名称 </label>
    <div class="col-sm-9">
        <input type="text" name="name" id="name" placeholder="分类名称" class="col-xs-10 col-sm-5" value="{$category.name}" required="required">
        <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">分类名称，不能为空。</span>
        </span>
    </div>
</div>
<div id="hide-url"{neq name="category.type" value="2"} class="hidden"{/neq}>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="url"> 外部连接 </label>
    <div class="col-sm-9">
        <input type="text" name="url" id="url" placeholder="外部连接" class="col-xs-10 col-sm-5" value="{$category.url}">
        <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">外部URL</span>
        </span>
    </div>
</div>
</div>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="keywords"> 关键词 </label>
    <div class="col-sm-9">
        <input type="text" name="keywords" id="keywords" placeholder="关键词" class="col-xs-10 col-sm-5" value="{$category.keywords}">
        <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">以逗号（,）隔开。</span>
        </span>
    </div>
</div>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="description"> 分类描述 </label>
    <div class="col-sm-9">
        <textarea name="description" id="description" class="col-xs-10 col-sm-5" rows="5" placeholder="分类描述">{$category.description}</textarea>
        <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle"></span>
        </span>
    </div>
</div>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="o"> 分类排序 </label>
    <div class="col-sm-9">
        <input type="number" name="o" id="o" placeholder="排序" class="col-xs-10 col-sm-5" value="{$category.o}">
        <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">越小越靠前。</span>
        </span>
    </div>
</div>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="listtemplate"> 列表模板 </label>
    <div class="col-sm-9">
        <input type="text" name="listtemplate" id="listtemplate" placeholder="列表模板" class="col-xs-10 col-sm-5" value="{$category.listtemplate}">
        <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">留空使用默认模板。</span>
        </span>
    </div>
</div>
<div class="space-4"></div>
<div class="form-group">
    <label class="col-sm-1 control-label no-padding-right" for="contenttemplate"> 内容模板 </label>
    <div class="col-sm-9">
        <input type="text" name="contenttemplate" id="contenttemplate" placeholder="内容模板" class="col-xs-10 col-sm-5" value="{$category.contenttemplate}">
        <span class="help-inline col-xs-12 col-sm-7">
            <span class="middle">留空使用默认模板。</span>
        </span>
    </div>
</div>
<div id="hide-content""{neq name="category.type" value="1"} class="hidden"{/neq}>>
    <div class="space-4"></div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="content"> 文章内容 </label>
        <div class="col-sm-9">
            <script id="content" name="content" type="text/plain" style="width:100%;height:400px;">{$category.content}</script>
        </div>
    </div>
</div>
<div class="col-md-offset-2 col-md-9">
    <button class="btn btn-info submit" type="submit">
        <i class="icon-ok bigger-110"></i>
        提交
    </button>

    &nbsp; &nbsp; &nbsp;
    <button class="btn" type="reset">
        <i class="icon-undo bigger-110"></i>
        重置
    </button>
</div>
</form>
{/block}
{block name="js_file"}
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.min.js"></script>
{/block}
{block name="javascript"}
<script type="text/javascript">
$(function() {
    var ue = UE.getEditor('content');
    $("#type").on('change',function(){
        var val = $(this).val();
        $("#hide-url").addClass('hidden');
        $("#hide-content").addClass('hidden');
        if (val == 1) {
            $("#hide-content").removeClass('hidden');
        }
        if (val == 2) {
            $("#hide-url").removeClass('hidden');
        }
    })
})
</script>
{/block}